<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('模型管理')" />
</head>
<body class="gray-bg">
    <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="notice-form">
					<div class="select-list">
						<ul>
							<li>
								分类：<select name="suspendState" th:with="type=${@dict.getType('act_category')}">
									<option value="">全部分类</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-table"></table>
	        </div>
    	</div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('activiti:definition:edit')}]];
        var removeFlag = [[${@permission.hasPermi('activiti:definition:remove')}]];
        var categorys = [[${@dict.getType('act_category')}]];
        var datas = [[${@dict.getType('bpm_def_status')}]];
        var prefix = ctx + "activiti/definition";

        $(function() {
            var options = {
                url: prefix + "/modelList",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "模型管理",
                columns: [
				{
					field : 'category',
					title : '流程分类',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(categorys, value);
					}
				},
				{
		            field: 'id',
		            title: '模型ID'
		        },
				{
					field: 'key',
					title: '模型标识'
				},
				{
					field: 'name',
					title: '模型名称'
				},
				{
		            field: 'version',
		            title: '版本号'
		        },
				{
					field: 'createTime',
					title: '创建时间'
				},
				{
					field: 'lastUpdateTime',
					title: '最后更新时间'
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="OnlineModificationProcess(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="suspendOrActiveApply(\'' + row.id + '\')"><i class="fa fa-remove"></i>部署</a>');
						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="suspendOrActiveApply(\'' + row.id + '\')"><i class="fa fa-remove"></i>导出</a>');
						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a> ');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

		function OnlineDrawingProcess() {
			this.modelVisible = true;
			localStorage.setItem("VUE_APP_BASE_API", process.env.VUE_APP_BASE_API)
			this.modelerUrl = "/bpmnjs/index.html?type=addBpmn";
		}

		function OnlineModificationProcess(data) {
			this.modelVisible = true;
			localStorage.setItem("VUE_APP_BASE_API", process.env.VUE_APP_BASE_API)
			this.modelerUrl = '/bpmnjs/index.html?type=lookBpmn&deploymentFileUUID=' + data.deploymentId + '&deploymentName=' + encodeURI(data.resourceName);
		}

		function handleImport() {
			this.upload.title = "上传模型图";
			this.upload.open = true;
		}
    </script>
</body>
</html>